#include "Game Engine/Header/Static.h"
#include "Game Engine/Header/Camera.h"

Static::Static()
{
	mPosition	= D3DXVECTOR3( 0.0f, 0.0f, 0.0f );
	mVelocity	= D3DXVECTOR3( 0.0f, 0.0f, 0.0f );
}

Static::~Static()
{
}

D3DXVECTOR3& Static::GetPosition()
{
	return mPosition;
}

D3DXVECTOR3& Static::GetVelocity()
{
	mVelocity.y *= 0.6f;
	mVelocity.x *= 0.6f;
	mVelocity.z *= 0.6f;

	return mVelocity;
}

void Static::SetPosition( D3DXVECTOR3 pos )
{
	mPosition = pos;

	D3DXMatrixTranslation( &mWorld, pos.x, pos.y, pos.z );

	mBody->translate( BTVector3( mPosition ) );
}

void Static::SetVelocity( D3DXVECTOR3 vel )
{
	mVelocity = vel;
}

void Static::Strafe( float d )
{
	D3DXVECTOR3 r = GetCamera().GetCameraRight();
	mVelocity += d * GetCamera().GetCameraRight();
}

void Static::Walk( float d )
{
	mVelocity += d * GetCamera().GetCameraLook();
	//mVelocity.x += d * GetCamera().GetCameraLook().x;
	//mVelocity.z += d * GetCamera().GetCameraLook().z;
}

void Static::Init( Mesh* mesh, Object::Shape shape, bool dynamic )
{
	Object::Init( mesh, shape, dynamic );

	mBody = Object::GetBody();
	mMesh = mesh;
}

void Static::FixedPosition( D3DXVECTOR3& pos )
{
	Object::FixedPosition( pos );
}

void Static::FixedRotation( float angle )
{
	Object::FixedRotation( angle );
}

void Static::Draw( D3DXMATRIX& lightViewProj, D3DXMATRIX& mat )
{
	//btMotionState* ms = mBody->getMotionState();
	//if(ms == NULL)return;

	//D3DXMATRIX T = BT2DX_MATRIX( *ms );

	mMesh->Draw( mWorld, lightViewProj );
}

D3DXMATRIX& Static::World()
{
	return mWorld;
}